<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>blog 留言板</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="css/blog.cmn.css">
    <link rel="stylesheet" href="css/message.css">
    <!--<script type="text/javascript" src="js/helium.js" onload="helium.init()" async></script>-->
</head>
<body>
<div id="blogheader"></div>
<article>
    <div id="blogaside"></div>
    <main class="r_box">
        <ul class="about">
            在线留言板
            <textarea id="kdeditor" style="width:100%;height:200px;resize:vertical" placeholder="100字以内"></textarea>
            <button onclick="doSubmit()" style="cursor:pointer;margin-top:10px;padding:3px 8px;">提交</button>
        </ul>
    </main>
</article>
<div id="blogfooter"></div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/hc-sticky.js"></script>
<script type="text/javascript" src="js/blog.cmn.js"></script>
<script type="text/javascript" src="js/countUp.min.js"></script>
<script type="text/javascript" src="js/vue.min.js"></script>
<script type="text/javascript" src="js/kindeditor/kindeditor-all-min.js"></script>
<script type="text/javascript" src="js/kindeditor/zh-CN.js"></script>
<script type="text/javascript" src="js/message.min.js"></script>
<script type="text/javascript">
    $("#blogheader").load("public/header.html");
    $("#blogaside").load("public/aside.html");
    $("#blogfooter").load("public/footer.html", function () {
        setTimeout(function () {
            var sc = document.createElement("script");
            sc.src = "js/blog.cmn.js";
            $("body").append(sc);
        }, 300)
    })

    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('#kdeditor');
    });

    function doSubmit() {
        if (editor.isEmpty()) {
            $.message({
                message: '留言不能为空',
                type: 'warning'
            });
            return;
        }
        $.ajax({
            url: 'feedback/add',
            data: JSON.stringify({'type': 2, 'content': editor.html()}),
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            type: 'post',
            success: function (data) {
                console.log(data);
                if (data.status == 0) {
                    editor.html('');
                    $.message('提示成功');
                } else {
                    $.message({
                        message: '提示失败，请稍后再试。',
                        type: 'info'
                    });
                }
            }
        });
    }
</script>
</body>
</html>
